package zy010;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class zy3 {
	public static void main(String[] args) throws IOException {
		File src=new File("d:\\aa\\src");
		File dest=new File("d:\\aaa\\dest");
		Copydir(src,dest);

	}

	private static void Copydir(File src, File dest) throws IOException {
		File[] listFiles = src.listFiles();
		if(listFiles!=null){
			for(File file:listFiles){
				if(file.isFile()){
					FileInputStream fis=new FileInputStream(file);
					FileOutputStream fos=new FileOutputStream(dest);
					byte[] buf=new byte[1024];
					int len=0;
					while((len=fis.read(buf))!=-1){
						fos.write(buf,0,len);
					}
				}else{
					Copydir(file, dest);
				}
			}
		}
		
		
	}
	
}
